<?php
namespace app\admin\model;

use think\Model;

class ArticleModel extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'ant_article';

    // 设置当前模型的数据库连接
    protected $connection = 'db_config';

    public function index( $param=[], $field="*" )
    {
        $list = $this
            ->where($param['searchData'])
            ->where([
                'is_delete' => 1
            ])
            ->limit(($param['pageNo'] - 1) * $param['pageSize'], $param['pageSize'])
            ->order('sort desc,id desc')
            ->field( $field )
            ->select()
        ;
        return $list;
    }

    public function dataNum( $param=[] )
    {
        return  $this
            ->where($param['searchData'])
            ->where([
                'is_delete' => 1
            ])
            ->count()
        ;
    }

    public function getInfoByWhere( $where = [], $field="*" )
    {
        $info = $this
            ->where( $where )
            ->field( $field )
            ->find();
        return empty($info) ? [] : $info->toArray();
    }

}